#pragma once
#include <stdint.h>
#include <string>
#include <glm/glm.hpp>
class Picture
{
public:
    uint8_t * data=nullptr;
    int width=0;
    int height=0;
    int channels=0;
    int formtype=0;

    Picture(){};
    Picture(const Picture& other);
    Picture(Picture&& other) noexcept;
    Picture(const char *path);

    std::string to_string(); 
    Picture SplitImage( int x1,int y1,int x2,int y2);
    
    Picture operator*(const glm::vec3 color)
    {
        for (int y = 0; y < height; y++)
        {
            for (int x = 0; x < width; x++)
            {
                for (int c = 0; c < 3; c++)
                {
                    int tmp = data[(y * width + x) * channels + c] * color[c];
                    if (tmp > 255)
                    {
                        tmp = 255;
                    }
                    data[(y * width + x) * channels + c] = tmp;
                }
            }
        }
        return *this;
    }

    Picture operator+(const glm::ivec3 color)
    {
        for (int y = 0; y < height; y++)
        {
            for (int x = 0; x < width; x++)
            {
                for (int c = 0; c < 3; c++)
                {
                    int tmp = data[(y * width + x) * channels + c] + color[c];
                    if (tmp > 255)
                    {
                        tmp = 255;
                    }
                    data[(y * width + x) * channels + c] = tmp;
                }
            }
        }
        return *this;
    }


    ~Picture();
};





